/**
 *    Copyright 2009-2019 the original author or authors.
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */
package org.apache.ibatis.reflection.factory;

import java.util.List;
import java.util.Properties;

/**
 * mybatis的对象创建工厂
 *
 * @author Clinton Begin
 */
public interface ObjectFactory {

    /**
     * 配置运行时需要使用的参数
     *
     * @param properties configuration properties 配置参数
     */
    void setProperties(Properties properties);

    /**
     * 使用默认的构造方法创建一个指定类型的实例
     *
     * @param type 指定类型
     */
    <T> T create(Class<T> type);

    /**
     * 通过构造方法和构造参数创建一个指定类型的实例
     * .
     *
     * @param type                指定对象类型
     * @param constructorArgTypes 构造参数类型集合
     * @param constructorArgs     构造参数集合
     */
    <T> T create(Class<T> type, List<Class<?>> constructorArgTypes, List<Object> constructorArgs);

    /**
     * 如果此对象可以包含一组其他对象则返回true，该方法的目的是为了兼容非Collection的集合。
     *
     * @param type 对象类型
     * @return 是否是一个集合
     * @since 3.1.0
     */
    <T> boolean isCollection(Class<T> type);

}
